package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.LbsPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * created by wangjunfu on 2021-07-05 11:06:16
 */
public class LbsPointDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(LbsPointDao.class);

    public LbsPoint insert(final LbsPoint lbsPoint) {
        insert("LbsPoint.insert", lbsPoint);
        return lbsPoint;
    }

    public Boolean updateInfoById(final LbsPoint lbsPoint) {
        return update("LbsPoint.updateInfoById", lbsPoint) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("LbsPoint.updateInfoByQuery", query) > 0;
    }

    public LbsPoint selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("LbsPoint.selectById", query);
    }

    public List<LbsPoint> selectByQuery(final Query query) {
        return queryForList("LbsPoint.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("LbsPoint.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        LbsPoint lbsPoint = new LbsPoint();
        lbsPoint.setDeleteFlag(1);
        lbsPoint.setId(id);
        lbsPoint.setEntId(entId);

        return update("LbsPoint.updateInfoById", lbsPoint) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("LbsPoint.deleteById", query) > 0;
    }
}